package com.xiahui.day01;

/**
 * 赋值运算符：= += -= *= /=
 */
public class TestAssignmentOperator {
    public static void main(String[] args) {
        int a = 10;
        a += 10;//a=a+10  20
        System.out.println("a = " + a);
        a -= 5;//a=a-5  15
        System.out.println("a = " + a);
        a *= 10;//a=a*10  150
        System.out.println("a = " + a);
        a /= 2;//a=a/2  75
        System.out.println("a = " + a);
        a %= 3;//a=a%3  0
        System.out.println("a = " + a);

        System.out.println("---------------------------------------------");

        short s1=10;
        s1+=10;//这里JVM帮我们实现 隐式 类型转换
        System.out.println("s1 = " + s1);

        short s2=10;
        s2 = (short) (s2+10);//这里因为是我们完整书写表达式进行计算和赋值 所以需要手动进行类型转换
        System.out.println("s2 = " + s2);
    }
}
